# Contributor: Eivind Uggedal <eu@eju.no>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=hiredis
pkgver=1.0.0
pkgrel=0
pkgdesc="Minimalistic C client library for Redis"
url="https://github.com/redis/hiredis"
arch="all"
license="BSD-3-Clause"
makedepends="openssl-dev"
checkdepends="redis"
subpackages="$pkgname-ssl $pkgname-dev"
source="$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz"


build() {
	make USE_SSL=1 PREFIX=/usr DEBUG="$CFLAGS" LDFLAGS="$LDFLAGS"
}

check() {
	redis-server --dir "$builddir" --unixsocket "$builddir"/redis.sock&
	local _redispid=$!

	# make sure socket is available before we start running tests
	local _n=100 # wait up to 10 sec
	while ! [ -e "$builddir"/redis.sock ] && [ $_n -gt 0 ]; do
		sleep 0.1s
		let _n="$_n - 1"
	done

	make hiredis-test
	./hiredis-test -s "$builddir"/redis.sock || (kill $_redispid && false)
	kill $_redispid
}

package() {
	make USE_SSL=1 PREFIX="$pkgdir"/usr install
}

ssl() {
	amove usr/lib/libhiredis_ssl.so*
}

sha512sums="eb56201121eecdbfc8d42e8c2c141ae77bea248eeb36687ac6835c9b2404f5475beb351c4d8539d552db4d88e933bb2bd5b73f165e62b130bb11aeff39928e69  hiredis-1.0.0.tar.gz"
